home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / TDROPFL.ZIP / TDropFile / Demo / Demo Source (Delphi) / Unit1.~pa < prev    next >
Encoding:
Text File  |  1998-02-14  |  1.3 KB  |  61 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   DropFile, ComCtrls, StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Image1: TImage;
  12.     Memo1: TMemo;
  13.     Label1: TLabel;
  14.     StatusBar1: TStatusBar;
  15.     DropFile1: TDropFile;
  16.     procedure DropFile1FileDrop(Sender: TObject; Filename: string);
  17.     procedure FormShow(Sender: TObject);
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32.  
  33. procedure TForm1.DropFile1FileDrop(Sender: TObject; Filename: string);
  34. var
  35.   F: TextFile;
  36.   S: string;
  37. begin
  38.   memo1.clear;
  39.   AssignFile(F, FileName);   { FileName returned from TDropFile component }
  40.   StatusBar1.SimpleText:= fileName + ' was dropped';
  41.   Reset(F);
  42.   while not EOF(F) do
  43.     begin
  44.       Readln(F, S);          { Read the first line out of the file }
  45.       Memo1.Lines.add(S);    { Put string in a TMemo control }
  46.     end;
  47.   CloseFile(F);
  48. end;
  49.  
  50. procedure TForm1.FormShow(Sender: TObject);
  51. begin
  52.   DropFile1.enableDropFile(form1.handle);
  53. end;
  54.  
  55. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  56. begin
  57.   dropFile1.disableDropFile;
  58. end;
  59.  
  60. end.
  61.